package com.study.zzedu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.google.gson.JsonObject;
import com.study.zzedu.R;

import org.json.JSONArray;
import org.json.JSONObject;

/**
 * 作者：Russell on 2021/1/7 11:16
 */

public class TeachersCourseAdapter2 extends BaseAdapter {
    private Context mContext;
    private JSONArray jArray;

    public TeachersCourseAdapter2(Context context, JSONArray jsonArray) {
        this.mContext = context;
        this.jArray = jsonArray;
    }

    @Override
    public int getCount() {
        return jArray.length();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.course_item_option2,parent,false);
        try {
            JSONObject job = jArray.getJSONObject(position);
            TextView tv = v.findViewById(R.id.tv_course_name);
            tv.setText(job.getString("name"));
        }catch (Exception e){
            e.toString();
            return v;
        }
        return v;
    }
}